import pickle


def get_class_names(raw_dir):
    """从元数据获取类别名称"""
    meta_path = raw_dir / "batches.meta"
    with open(meta_path, 'rb') as f:
        meta = pickle.load(f, encoding='bytes')
    return [name.decode('utf-8') for name in meta[b'label_names']]


def verify_structure(processed_dir):
    """验证目录结构是否正确"""
    required = {
        'train': ['airplane', 'automobile', 'bird', 'cat', 'deer',
                  'dog', 'frog', 'horse', 'ship', 'truck'],
        'test': ['airplane', 'automobile', 'bird', 'cat', 'deer',
                 'dog', 'frog', 'horse', 'ship', 'truck']
    }

    for split, classes in required.items():
        split_dir = processed_dir / split
        if not split_dir.exists():
            return False

        for cls in classes:
            if not (split_dir / cls).exists():
                return False

    return True
